package com.um.jdy.common.charge.service.impl;

import com.um.jdy.common.device.dao.FeeEvPriceDao;
import com.um.jdy.common.device.entity.po.FeeEvPrice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
import com.um.springboot.starter.orm.service.BaseEntityServiceImpl;
import com.um.jdy.common.charge.service.OrderEvPriceService;
import com.um.jdy.common.charge.dao.OrderEvPriceDao;
import com.um.jdy.common.charge.entity.po.OrderEvPrice;

import java.util.List;

/**
 * 服务实现类：汽车桩-价格类别表
 */
@Service
@Transactional
@Slf4j
public class OrderEvPriceServiceImpl extends BaseEntityServiceImpl<OrderEvPriceDao,OrderEvPrice>  implements OrderEvPriceService{

    @Autowired
    FeeEvPriceDao feeEvPriceDao;

    /**
     * 添加汽车桩价格表
     *
     * @param feeId
     * @param orderId
     */
    @Override
    public void addOrderEvPrice(String feeId, String orderId) {
        List<FeeEvPrice> prices = feeEvPriceDao.getRows(new String[]{"device_fee_id"},new Object[]{feeId},
                new String[]{"sort_no"},new String[]{"asc"});
        for(FeeEvPrice price : prices){
            OrderEvPrice item = new OrderEvPrice();
            item.setChargeOrderId(orderId);
            item.setComId(price.getComId());
            item.setType(price.getType());
            item.setServiceFee(price.getServiceFee());
            item.setUnitPrice(price.getUnitPrice());
            item.setSortNo(price.getSortNo());
            this.saveRow(item);
        }
    }
}
